﻿using BW.MesProject.Equipment.Infrastructure.Dto.Input.ProjectMaintenance;
using BW.MesProject.Equipment.Infrastructure.Dto.Output.ProjectMaintenance;
using BW.MesProject.Equipment.Infrastructure.Equipment;
using BW.MesProject.Public.ErrorCode;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BW.MesProject.Equipment.Host.Controllers
{
    /// <summary>
    /// 项目维护控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProjectMaintenanceController : ControllerBase
    {
        private readonly IProjectMaintenanceService _projectMaintenanceService;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="projectMaintenanceService"></param>
        public ProjectMaintenanceController(IProjectMaintenanceService projectMaintenanceService)
        {
            this._projectMaintenanceService = projectMaintenanceService;
        }
        /// <summary>
        /// 添加项目维护
        /// </summary>
        /// <param name="input">添加项目维护输入参数</param>
        /// <returns>返回操作结果，包含状态码、提示信息及受影响的行数</returns>
        [HttpPost]
        public ApiResult<int> AddProjectMaintenance([FromBody]AddProjectMaintenanceInput input)
        {
            return _projectMaintenanceService.AddProjectMaintenance(input);
        }

        /// <summary>
        /// 项目维护显示列表
        /// </summary>
        /// <param name="input">项目维护查询输入参数</param>
        /// <returns>返回分页后的项目维护输出列表</returns>
        [HttpGet]
        public ApiPaging<ProjectMaintenanceOutput> GetProjectMaintenanceList([FromQuery]ProjectMaintenanceQueryInput input)
        {
            return _projectMaintenanceService.GetProjectMaintenanceList(input);
        }

        /// <summary>
        /// 逻辑删除项目维护数据
        /// </summary>
        /// <param name="id">项目维护ID</param>
        /// <returns>返回操作结果，包含状态码、提示信息及受影响的行数</returns>
        [HttpDelete]
        public ApiResult<int> DeleteProjectMaintenance(long id)
        {
            return _projectMaintenanceService.DeleteProjectMaintenance(id);
        }

        /// <summary>
        /// 根据项目维护ID查询项目维护数据
        /// </summary>
        /// <param name="id">项目维护ID</param>
        /// <returns>返回操作结果，包含状态码、提示信息及项目维护输出数据</returns>
        [HttpGet]
        public ApiResult<ProjectMaintenanceOutput> GetProjectMaintenanceValue([FromQuery]long id)
        {
            return _projectMaintenanceService.GetProjectMaintenanceValue(id);
        }

        /// <summary>
        /// 修改项目维护
        /// </summary>
        /// <param name="input">修改项目维护输入参数</param>
        /// <returns>返回操作结果，包含状态码、提示信息及受影响的行数</returns>
        [HttpPut]
        public ApiResult<int> UpdateProjectMaintenance([FromBody]UpdateProjectMaintenanceInput input)
        {
            return _projectMaintenanceService.UpdateProjectMaintenance(input);
        }
    }
}
